package com.spddr.pmos.cxf.tree.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Service;

import com.spddr.pmos.cxf.tree.JaxrsSecTree;
import com.spddr.pmos.jpa.TradeWay;

import cn.seqdata.jpa.JpaAuditableObject;
import cn.seqdata.pojo.TreeNode;


@Service
public class JaxrsSecTreeImpl extends AbstractTreeImpl implements JaxrsSecTree {

	@Override
	public Collection<TreeNode> byRoot() {
		List<TreeNode> nodes = new ArrayList<>();
		List<TradeWay> li = new ArrayList<TradeWay>();
		TradeWay tradeWay_one = tradeWayRepos.findOne(1L);
		TradeWay tradeWay_two = tradeWayRepos.findOne(2L);
		TradeWay tradeWay_three = tradeWayRepos.findOne(3L);
		TradeWay tradeWay_four = tradeWayRepos.findOne(4L);
		TradeWay tradeWay_five = tradeWayRepos.findOne(5L);
		li.add(tradeWay_one);
		li.add(tradeWay_two);
		li.add(tradeWay_three);
		li.add(tradeWay_four);
		li.add(tradeWay_five);
		for (int i = 0; i < li.size(); i++) {
			nodes.addAll(byJpaObject(true, Arrays.asList(li.get(i))));
		}
		return nodes;
	}
	public Collection<TreeNode> byOneNodeId(String args){
		List<TreeNode> nodes = new ArrayList<>();
		List<TradeWay> li = new ArrayList<TradeWay>();
		if(args!=null){
			if(args=="1"||args.equals("1")){
				TradeWay tradeWay_one = tradeWayRepos.findOne(1L);
				li.add(tradeWay_one);
			}else if(args=="2"||args.equals("2")){
				TradeWay tradeWay_two = tradeWayRepos.findOne(2L);
				li.add(tradeWay_two);
			}else if(args=="3"||args.equals("3")){
				TradeWay tradeWay_three = tradeWayRepos.findOne(3L);
				li.add(tradeWay_three);
			}else if(args=="4"||args.equals("4")){
				TradeWay tradeWay_four = tradeWayRepos.findOne(4L);
				li.add(tradeWay_four);
			}else if(args=="5"||args.equals("5")){
				TradeWay tradeWay_five = tradeWayRepos.findOne(5L);
				li.add(tradeWay_five);
			}
		for (int i = 0; i < li.size(); i++) {
			nodes.addAll(byJpaObject(true, Arrays.asList(li.get(i))));
		}
		
		}
		return nodes;
	}

}
